/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.proyecto.datos;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;

/**
 *
 * @author mario
 */
public class EntityPregunta implements OperacionesDB {
    
    private int id;
    private String pregunta;

    public EntityPregunta() {
    }

    public EntityPregunta(int id, String pregunta) {
        this.id = id;
        this.pregunta = pregunta;
    }

    public String getPregunta() {
        return pregunta;
    }

    public void setPregunta(String pregunta) {
        this.pregunta = pregunta;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Override
    public String EjecutarComando(String cadenaSQL) {
        throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
    }

    @Override
    public ArrayList EjecutarConsulta(String cadenaSQL) {
        ArrayList arry = new ArrayList();
        Connection cn;
        Statement st;
        ResultSet rs;

        try {

            ConnDB db = new ConnDB();
            Class.forName(db.getDriver());
            cn = DriverManager.getConnection(db.getCadenaCon(), db.getUsuario(), db.getContrasenna());

            st = cn.createStatement();
            rs = st.executeQuery(cadenaSQL);
            rs.beforeFirst();
            while (rs.next()) {
                arry.add(new EntityPregunta(rs.getInt("pre.id_pregunta"), rs.getString("pre.pregunta")));
            }
            rs.close();
            st.close();
            cn.close();



        } catch (Exception ex) {

            arry = null;
            System.out.println(ex.toString());
        }

        return arry;


    }
    
    
    
}
